package pc;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class demo1 {
    public static void main(String[] args) throws IOException {
        String u1 = "http://www.haoming8.cn/baobao/10881.html";
        String s = Web(u1);
        System.out.println(s);
    }

    public static String Web(String u) throws IOException {
        StringBuilder sb = new StringBuilder();
        URL url = new URL(u);
        //链接网址
        URLConnection conn = url.openConnection();
        //解析网址
        InputStreamReader isr = new InputStreamReader(conn.getInputStream());

        int c;
        // 按行读取网页内容
        while ((c =  isr.read()) != -1) {
            sb.append((char)c);
        }
        isr.close();
        String string = sb.toString();
        return string;
    }
}
